package com.ruoyi.finance.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author: lrz
 * @Date: 2025/2/24 14:01
 * @Description:
 **/
@Component
public class MyIndustryConfig implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createId", Long.class, SecurityUtils.getUserId());
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
        this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
        this.strictInsertFill(metaObject,"deleteType",Long.class,1L);
        this.strictInsertFill(metaObject,"bbNumber",Long.class,1L);
        this.strictInsertFill(metaObject,"createUser",String.class,SecurityUtils.getUsername());
        this.strictInsertFill(metaObject,"updateUser",String.class,SecurityUtils.getUsername());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"updateUser",String.class,SecurityUtils.getUsername());
        this.strictUpdateFill(metaObject, "updateId", Long.class, SecurityUtils.getUserId());
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }
}
